<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime : 2020-01-14 10:02:39
 * @LastEditors  : Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .row {
            margin-top: 10px;
            position: relative;
        }

        .row:last-child {
            margin-bottom: 10px;
        }

        .row .delete {
            position: absolute;
            left: 0;
            width: 0;
            top: 0;
            bottom: 0;
            text-align: center;
            line-height: 68px;
            background: #fff;
            transition: all .4s;
        }

        .row .delete img {
            width: 25px;
        }

        .showDelete {
            width: 40px !important;
        }

        .row-info {
            margin-left: 0;
            overflow: hidden;
            width: 100%;
            transition: all .4s;
        }

        .m-r {
            margin-left: 40px;
        }

        .ov {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
        }

        /* .van-cell__value {
            text-align: right;
        } */

        .label {
            font-weight: 500;
            font-size: 13px;
            color: #969799;
        }

        .seal {
            width: 60px;
            top: 0;
            right: 0;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head" :title="moduleType" left-arrow @click-left="onClickLeft">
                <div slot="right" class="head-right">
                    <span @click="showSearch = true;">
                        <img src="../image/search.png" />
                    </span>
                </div>
            </van-nav-bar>
            <div class="body-no-bottom">
                <div class="content">
                    <van-tabs v-model="tabActive">
                        <van-tab>
                            <div slot="title">待受理<b style="color: #cd1b21;">({{total1}})</b></div>
                            <van-list v-model="listLoading1" :finished="listFinished1" finished-text="没有更多了"
                                @load="listOnLoad(1)">
                                <div class="row" v-for="(row,index) in dataList1" @click="intoRow(row)">
                                    <van-cell clickable>
                                        <div>
                                            <van-row gutter="20">
                                                <van-col span="14" class="ov">{{row.ClientName}}</van-col>
                                                <van-col span="10">{{row.BillDate}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">合计数量:{{parseInt(row.SumNum)}}</van-col>
                                                <van-col span="12">合计金额:{{row.SumMoney}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">业务类型:{{row.TPName}}</van-col>

                                            </van-row>
                                        </div>
                                        <img class="seal" :src="getSealImage(row)" v-if="row.IsPayZT!=0" />
                                        <img class="seal" src="../image/ysl.png" v-if="row.CGZT == 2" />
                                        <img class="seal" src="../image/th.png" v-if="row.CGZT == 3" />
                                    </van-cell>

                                </div>
                            </van-list>
                        </van-tab>
                        <van-tab>
                            <div slot="title">未拣货<b style="color: #cd1b21;">({{total2}})</b></div>
                            <van-list v-model="listLoading2" :finished="listFinished2" finished-text="没有更多了"
                                @load="listOnLoad(2)">
                                <div class="row" v-for="(row,index) in dataList2" @click="intoRow(row)">
                                    <van-cell clickable>
                                        <div>
                                            <van-row gutter="20">
                                                <van-col span="14" class="ov">{{row.ClientName}}</van-col>
                                                <van-col span="10">{{row.BillDate}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">合计数量:{{parseInt(row.SumNum)}}</van-col>
                                                <van-col span="12">合计金额:{{row.SumMoney}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">业务类型:{{row.TPName}}</van-col>
                                            </van-row>
                                        </div>
                                        <img class="seal" :src="getSealImage(row)" v-if="row.IsPayZT!=0" />
                                    </van-cell>
                                </div>
                            </van-list>
                        </van-tab>
                        <van-tab>
                            <div slot="title">拣货中<b style="color: #cd1b21;">({{total3}})</b></div>
                            <van-list v-model="listLoading3" :finished="listFinished3" finished-text="没有更多了"
                                @load="listOnLoad(3)">
                                <div class="row" v-for="(row,index) in dataList3" @click="intoRow(row)">
                                    <van-cell clickable>
                                        <div>
                                            <van-row gutter="20">
                                                <van-col span="14" class="ov">{{row.ClientName}}</van-col>
                                                <van-col span="10">{{row.BillDate}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">合计数量:{{parseInt(row.SumNum)}}</van-col>
                                                <van-col span="12">合计金额:{{row.SumMoney}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">业务类型:{{row.TPName}}</van-col>
                                            </van-row>
                                        </div>
                                        <img class="seal" :src="getSealImage(row)" v-if="row.IsPayZT!=0" />
                                    </van-cell>
                                </div>

                            </van-list>
                        </van-tab>
                        <van-tab title="已完成">
                            <van-list v-model="listLoading4" :finished="listFinished4" finished-text="没有更多了"
                                @load="listOnLoad(4)">
                                <div class="row" v-for="(row,index) in dataList4" @click="intoRow(row)">
                                    <van-cell clickable>
                                        <div>
                                            <van-row gutter="20">
                                                <van-col span="14" class="ov">{{row.ClientName}}</van-col>
                                                <van-col span="10">{{row.BillDate}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">合计数量:{{parseInt(row.SumNum)}}</van-col>
                                                <van-col span="12">合计金额:{{row.SumMoney}}</van-col>
                                            </van-row>
                                        </div>
                                        <div class="label">
                                            <van-row gutter="20">
                                                <van-col span="12">业务类型:{{row.TPName}}</van-col>
                                                <van-col span="12">过账时间:{{row.APDate}}</van-col>
                                            </van-row>
                                        </div>
                                        <img class="seal" :src="getSealImage(row)" v-if="row.IsPayZT!=0" />
                                    </van-cell>
                                </div>

                            </van-list>
                        </van-tab>
                    </van-tabs>

                </div>
                <van-loading v-if="showLoading" />
            </div>
        </div>

        <van-popup v-model="showSearch" round position="bottom">
            <div>
                <van-cell title="往来单位" :value="searchData.S_ClientName" is-link @click="openScreen(-1,10)">
                </van-cell>
                <van-cell title="仓库" :value="searchData.S_StockName" is-link @click="openScreen(-1,36)">
                </van-cell>
                <van-cell title="业务类型" :value="searchData.S_TPName" is-link @click="openScreen(-1,210)">
                </van-cell>
                <van-cell title="时间" :value="searchData.S_SDate" @click="openDate(1)">
                </van-cell>
                <!-- <van-cell title="结束时间" :value="searchData.S_EDate" @click="openDate(2)">
                </van-cell> -->
            </div>
            <div class="btn-padding">
                <van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
            </div>
        </van-popup>


        <van-popup v-model="showDate" round position="bottom">
            <van-datetime-picker v-model="currentDate" type="year-month" @confirm="confirmDate" @cancel="cancelDate"
                cancel-button-text="清空" />
        </van-popup>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            vm.onClickLeft();
        });

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            var selectType = ret.value.selectType;
            var type = ret.value.type;
            var row = ret.value.row;
            if (selectType == 10) {
                if (row) {
                    vm.searchData.S_ClientName = row.name;
                    vm.searchData.S_ClientID = row.id;
                } else {
                    vm.searchData.S_ClientName = '';
                    vm.searchData.S_ClientID = 0;
                }

            } else if (selectType == 36) {
                if (row) {
                    vm.searchData.S_StockName = row.name;
                    vm.searchData.S_StockID = row.id;
                } else {
                    vm.searchData.S_StockName = '';
                    vm.searchData.S_StockID = 0;
                }
            } else if (selectType == 210) {
                if (row) {
                    vm.searchData.S_TPName = row.name;
                } else {
                    vm.searchData.S_TPName = '';
                }
            }

        });

        api.addEventListener({
            name: 'refreshList'
        }, function (ret, err) {
            var type = ret.value.type;
            vm['pageIndex' + type] = 1;
            var obj = {
                S_B_Type: type,
                S_BillType: vm.type,
                S_Pageindex: vm['pageIndex' + type],
                S_PageSize: vm['pageSize' + type],
                S_ClientID: vm.searchData.S_ClientID,
                S_BranchID: vm.searchData.S_BranchID,
                S_SDate: vm.searchData.S_SDate + (vm.searchData.S_SDate ? '-01' : ''),
                S_EDate: vm.searchData.S_SDate + (vm.searchData.S_SDate ? '-01' : ''),
                S_StockID: vm.searchData.S_StockID,
                S_TPName: vm.searchData.S_TPName,
                S_OrderN: 0,
                S_TPLX: vm.moduleType == '出货跟踪' ? 0 : 1
            }
            FLD.ajax('AP_HisList_XSZB', obj, function (res) {
                vm['listFinished' + type] = false;
                vm['dataList' + type] = res.ds;
                vm['total' + type] = res.ds1[0]['@TotalCount'];
            })
        })
        var tabActive = api.pageParam.tabActive === undefined ? 0 : api.pageParam.tabActive;
        var userInfo = FLD.getUserInfo();
        var dateIndex = 0;
        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,
                type: -101,
                moduleType: api.pageParam.type,
                tabActive: parseInt(tabActive),
                listLoading1: false,
                listFinished1: true,
                listLoading2: false,
                listFinished2: true,
                listLoading3: false,
                listFinished3: true,
                listLoading4: false,
                listFinished4: true,
                dataList1: [],
                dataList2: [],
                dataList3: [],
                dataList4: [],
                total1: 0,
                total2: 0,
                total3: 0,
                total4: 0,
                pageIndex1: 1,
                pageSize1: 20,
                pageIndex2: 1,
                pageSize2: 20,
                pageIndex3: 1,
                pageSize3: 20,
                pageIndex4: 1,
                pageSize4: 20,
                currentDate: new Date(),
                showDate: false,
                searchData: {
                    S_ClientID: 0,
                    S_ClientName: '',
                    S_StockID: 0,
                    S_StockName: '',
                    S_TPName: '',
                    S_BranchID: userInfo.S_BranchID,
                    S_SDate: '',
                    S_EDate: ''
                }

            },
            created: function () {
                this.getList();
            },
            methods: {
                getList() {
                    var that = this;
                    that.showLoading = true;
                    var obj1 = {
                        S_B_Type: 1,
                        S_BillType: that.type,
                        S_Pageindex: that.pageIndex1,
                        S_PageSize: that.pageSize1,
                        S_ClientID: that.searchData.S_ClientID,
                        S_BranchID: that.searchData.S_BranchID,
                        S_SDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_EDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_StockID: that.searchData.S_StockID,
                        S_TPName: that.searchData.S_TPName,
                        S_OrderN: 0,
                        S_TPLX: that.moduleType == '出货跟踪' ? 0 : 1
                    }
                    FLD.ajax('AP_HisList_XSZB', obj1, function (res) {
                        that.showLoading = false;
                        that.listFinished1 = false;
                        that.dataList1 = res.ds;
                        that.total1 = res.ds1[0]['@TotalCount'];

                    })
                    var obj2 = {
                        S_B_Type: 2,
                        S_BillType: that.type,
                        S_Pageindex: that.pageIndex2,
                        S_PageSize: that.pageSize2,
                        S_ClientID: that.searchData.S_ClientID,
                        S_BranchID: that.searchData.S_BranchID,
                        S_SDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_EDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_StockID: that.searchData.S_StockID,
                        S_TPName: that.searchData.S_TPName,
                        S_OrderN: 0,
                        S_TPLX: that.moduleType == '出货跟踪' ? 0 : 1
                    }
                    FLD.ajax('AP_HisList_XSZB', obj2, function (res) {
                        that.showLoading = false;
                        that.listFinished2 = false;
                        that.dataList2 = res.ds;
                        that.total2 = res.ds1[0]['@TotalCount'];
                    })
                    var obj3 = {
                        S_B_Type: 3,
                        S_BillType: that.type,
                        S_Pageindex: that.pageIndex3,
                        S_PageSize: that.pageSize3,
                        S_ClientID: that.searchData.S_ClientID,
                        S_BranchID: that.searchData.S_BranchID,
                        S_SDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_EDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_StockID: that.searchData.S_StockID,
                        S_TPName: that.searchData.S_TPName,
                        S_OrderN: 0,
                        S_TPLX: that.moduleType == '出货跟踪' ? 0 : 1

                    }
                    FLD.ajax('AP_HisList_XSZB', obj3, function (res) {
                        that.showLoading = false;
                        that.listFinished3 = false;
                        that.dataList3 = res.ds;
                        that.total3 = res.ds1[0]['@TotalCount'];
                    })
                    var obj4 = {
                        S_B_Type: 4,
                        S_BillType: that.type,
                        S_Pageindex: that.pageIndex4,
                        S_PageSize: that.pageSize4,
                        S_ClientID: that.searchData.S_ClientID,
                        S_BranchID: that.searchData.S_BranchID,
                        S_SDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_EDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_StockID: that.searchData.S_StockID,
                        S_TPName: that.searchData.S_TPName,
                        S_OrderN: 0,
                        S_TPLX: that.moduleType == '出货跟踪' ? 0 : 1

                    }
                    FLD.ajax('AP_HisList_XSZB', obj4, function (res) {
                        that.showLoading = false;
                        that.listFinished4 = false;
                        that.dataList4 = res.ds;
                        that.total4 = res.ds1[0]['@TotalCount'];
                    })
                },
                listOnLoad(index) {
                    var that = this;
                    that['pageIndex' + index]++;
                    var obj = {
                        S_B_Type: index,
                        S_BillType: that.type,
                        S_Pageindex: that['pageIndex' + index],
                        S_PageSize: that['pageSize' + index],
                        S_ClientID: that.searchData.S_ClientID,
                        S_BranchID: that.searchData.S_BranchID,
                        S_SDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_EDate: that.searchData.S_SDate + (that.searchData.S_SDate ? '-01' : ''),
                        S_StockID: that.searchData.S_StockID,
                        S_TPName: that.searchData.S_TPName,
                        S_OrderN: 0,
                        S_TPLX: that.moduleType == '出货跟踪' ? 0 : 1
                    }
                    FLD.ajax('AP_HisList_XSZB', obj, function (res) {
                        that['listLoading' + index] = false;
                        if (res.ds.length == 0) {
                            that['listFinished' + index] = true;
                        }
                        that['dataList' + index] = that['dataList' + index].concat(res.ds);
                    })
                },
                getSealImage(row) {
                    if (row.IsPayZT == 1) {
                        return '../image/confirmed.png';
                    }
                    if (row.IsPayZT == 2) {
                        return '../image/paying.png';
                    }
                    if (row.IsPayZT == 3) {
                        return '../image/payed.png';
                    }
                },
                searchList() {
                    var that = this;
                    that.showSearch = false;

                    that.pageIndex1 = 1;
                    that.pageIndex2 = 1;
                    that.pageIndex3 = 1;
                    that.pageIndex4 = 1;
                    this.getList();
                },
                openScreen(type, index) {
                    var obj = {
                        S_Type: index,
                        S_Cont: '',
                        S_BranchID: userInfo.S_BranchID,
                        S_SXZ: '',
                        S_StockID: userInfo.S_StockID,
                        S_CargoID: userInfo.S_CargoID,
                        S_BarCode: '',
                        S_PriceN: 0,
                        S_ProductID: 0
                    }

                    api.openWin({
                        name: '筛选' + index,
                        url: 'common/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: {
                            filterData: obj,
                            type: type,
                            allowClear: true
                        }
                    })

                },
                openDate(index) {
                    dateIndex = index;
                    this.currentDate = new Date()
                    this.showDate = true;
                },
                confirmDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = FLD.getFormatYearMonthTime(value)
                    } else {
                        this.searchData.S_EDate = FLD.getFormatYearMonthTime(value)
                    }
                    this.showDate = false;
                },
                cancelDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = ''
                    } else {
                        this.searchData.S_EDate = '';
                    }
                    this.showDate = false;
                },
                intoRow(row) {
                    var that = this;
                    var isDisabled = false;
                    if (that.moduleType == '收货跟踪') {
                        isDisabled = true;
                        if (that.tabActive == 0) {
                            isDisabled = false;
                        } else {
                            isDisabled = true;
                        }
                    }
                    api.openWin({
                        name: 'selling',
                        url: 'selling.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: {
                            historyData: row,
                            isDisabled: isDisabled
                        }
                    })

                },
                onClickLeft() {
                    api.sendEvent({
                        name: 'setOrientation'
                    });
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>